import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)
// 重复点击路由报错 NavigationDuplicated: Avoided redundant navigation to current location 报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  {
    path: '/home',
    name: 'home',
    redirect: '/analysis',
    component: () => import(/* webpackChunkName: "home" */ '../views/Home.vue'),
    children: [
      {
        path: '/analysis',
        name: 'Analysis',
        component: () => import(/* webpackChunkName: "analysis" */ '../views/DashBoard/Analysis.vue'),
        meta:{
          title:'首页',
          name:'analysis',
          comp: 'Analysis'
        }
      },
      // 添加房源
      {
        path: '/addhouse',
        name: 'Addhouse',
        component: () => import(/* webpackChunkName: "addhouse" */ '../views/HouseInfo/AddHouse.vue'),
        meta:{
          title:'添加房源',
          name:'addhouse',
          comp: 'AddHouse'
        }
      },
      // 房源列表
      {
        path: '/houselist',
        name: 'Houselist',
        component: () => import(/* webpackChunkName: "houselist" */ '../views/HouseInfo/HouseList.vue'),
        meta:{
          title:'房源列表',
          name:'houselist',
          comp: 'HouseList'
        }
      },
      // 退租申请
      {
        path: '/rentoutapply',
        name: 'rentoutapply',
        component: () => import(/* webpackChunkName: "rentoutapply" */ '../views/ApplyList/RentoutApply.vue'),
        meta:{
          title:'退租申请',
          name:'rentoutapply',
          comp:'RentoutApply'
        }
      },
      // 看房申请
      {
        path: '/viewhouse',
        name: 'viewhouse',
        component: () => import(/* webpackChunkName: "viewhouse" */ '../views/ApplyList/ViewHouse.vue'),
        meta:{
          title:'看房申请',
          name:'viewhouse',
          comp:'ViewHouse'
        }
      },

      // 在租列表
      {
        path: '/rentinglist',
        name: 'Rentinglist',
        component: () => import(/* webpackChunkName: "rentinglist" */ '../views/RentContract/RentingList.vue'),
        meta:{
          title:'在租列表',
          name:"rentinglist",
          comp: 'RentingList'
        }
      },
    
      // 已退租列表
      {
        path: '/rentingoutlist',
        name: 'Rentingoutlist',
        component: () => import(/* webpackChunkName: "rentingoutlist" */ '../views/RentContract/RentingoutList.vue'),
        meta:{
          title:'已退租列表',
          name:"rentingoutlist",
          comp: 'RentingoutList'
        }
      },
      // 我要收租
      {
        path: '/collectrent',
        name: 'collectrent',
        component: () => import(/* webpackChunkName: "collectrent" */ '../views/RentPriceInfo/CollectRent.vue'),
        meta:{
          title:'我要收租',
          name:"collectrent",
          comp: 'CollectRent'
        }
      },
      // 租客待缴租金
      {
        path: '/rentertopaid',
        name: 'rentertopaid',
        component: () => import(/* webpackChunkName: "rentertopaid" */ '../views/RentPriceInfo/RenterToPaid.vue'),
        meta:{
          title:'租客待缴租金',
          name:"rentertopaid",
          comp: 'RenterToPaid'
        }
      },
      // 租客已缴租金
      {
        path: '/renterpaided',
        name: 'renterpaided',
        component: () => import(/* webpackChunkName: "renterpaided" */ '../views/RentPriceInfo/RenterPaided.vue'),
        meta:{
          title:'租客已缴租金',
          name:"renterpaided",
          comp: 'RenterPaided'
        }
      },
      // 待处理报障
      
      {
        path: '/myobstruct',
        name: 'myobstruct',
        component: () => import(/* webpackChunkName: "processobstruct" */ '../views/ReportingObstacles/MyObstruct.vue'),
        meta:{
          title:'我要报障',
          name:'myobstruct',
          comp: 'MyObstruct'
        }
      },
      {
        path: '/processobstruct',
        name: 'processobstruct',
        component: () => import(/* webpackChunkName: "processobstruct" */ '../views/ReportingObstacles/ProcessObstruct.vue'),
        meta:{
          title:'待处理报障',
          name:'processobstruct',
          comp: 'ProcessObstruct'
        }
      },
      // 已处理保障
      {
        path: '/processedobstruct',
        name: 'processedobstruct',
        component: () => import(/* webpackChunkName: "processedobstruct" */ '../views/ReportingObstacles/ProcessedObstruct.vue'),
        meta:{
          title:'已处理保障',
          name:'processedobstruct',
          comp: 'ProcessedObstruct'
        }
      },
      // 查看日程
      {
        path: '/viewschedule',
        name: 'viewschedule',
        component: () => import(/* webpackChunkName: "viewschedule" */ '../views/MySchedule/ViewSchedule.vue'),
        meta:{
          title:'查看日程',
          name:'viewschedule',
          comp: 'ViewSchedule'
        }
      },
      // 添加日程
      {
        path: '/addschedule',
        name: 'addschedule',
        component: () => import(/* webpackChunkName: "addschedule" */ '../views/MySchedule/AddSchedule.vue'),
        meta:{
          title:'添加日程',
          name:'addschedule',
          comp: 'AddSchedule'
        }
      },
      {
        path: '/usermanage',
        name: 'usermanage',
        component: () => import(/* webpackChunkName: "usermanage" */ '../views/Other/UserManage.vue'),
        meta:{
          title:'用户管理',
          name:'usermanage',
          comp: 'UserManage'
        }
      },
      {
        path: '/userinfo',
        name: 'userinfo',
        component: () => import(/* webpackChunkName: "userinfo" */ '../views/Other/UserInfo.vue'),
        meta:{
          title:'账户绑定',
          name:'userinfo',
          comp: 'UserInfo'
        }
      }
      
    ]
  }
]

const router = new VueRouter({
  mode:'hash',
  base: '/',
  routes
})

export default router
